package com.tuteng.administrator.ashospital.AdapterManger;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.tuteng.administrator.ashospital.R;
import com.tuteng.administrator.ashospital.application.hospitalAppication;
import com.tuteng.administrator.ashospital.beans.FriendInfoBean;

import java.util.ArrayList;
import java.util.List;

public class ItemAdapter extends BaseAdapter {
    public List<DataHolder> list ;
    LayoutInflater inflater;
    public ItemAdapter(Context context, List<DataHolder> list){
        this.list = list;
        inflater = LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return list.size();
    }
    @Override
    public DataHolder getItem(int i) {
        if(i==getCount()|| list==null){
            return null;
        }
        return list.get(i);
    }
    @Override
    public long getItemId(int i) {
        return i;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder holder;
        if(convertView == null){
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.friend_dialog_list, null);

            holder.title = (TextView) convertView.findViewById(R.id.textview);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }

        holder.title.setText(getItem(position).title);
        return convertView;
    }
    public static class ViewHolder{

        public TextView title;
    }
    public static class DataHolder {
        public String title;

        //数据实体
        public DataHolder(String title){
            this.title = title;

        }
    }

    public  static   List<ItemAdapter.DataHolder> iniDatas(List<FriendInfoBean> beans1 ){

        List<FriendInfoBean> beans=beans1;
        List<ItemAdapter.DataHolder> list = new ArrayList<DataHolder>();
        for(int i=0;i<beans.size();i++)
        {    ItemAdapter.DataHolder dataHolder=new  ItemAdapter.DataHolder(beans.get(i).getPatientName());

            list.add(dataHolder);
        }
        return list;
    }

}
